package com.kexio.user.dto;

import java.time.LocalDateTime;
import java.util.List;

/**
 * 在线用户详细信息DTO
 * 
 * 🎯 主要用途：
 * 1. 返回丰富的在线用户统计信息
 * 2. 包含用户基本信息和会话详情
 * 3. 提供活跃度分析数据
 * 
 * @author Kexio Team
 * @since 2.2.0
 */
public class OnlineUserDetailDTO {
    
    /**
     * 统计信息
     */
    private OnlineStatistics statistics;
    
    /**
     * 在线用户列表
     */
    private List<OnlineUserInfo> users;
    
    /**
     * 会话分布统计
     */
    private SessionDistribution sessionDistribution;
    
    // ==================== 嵌套类 ====================
    
    /**
     * 在线统计信息
     */
    public static class OnlineStatistics {
        /**
         * 总在线用户数
         */
        private Long totalCount;
        
        /**
         * 活跃用户数（最近5分钟有活动）
         */
        private Long activeCount;
        
        /**
         * 空闲用户数（超过5分钟无活动）
         */
        private Long idleCount;
        
        /**
         * 今日登录用户数
         */
        private Long todayLoginCount;
        
        /**
         * 平均在线时长（分钟）
         */
        private Double averageOnlineMinutes;
        
        /**
         * 统计时间
         */
        private LocalDateTime statisticTime;
        
        // Getters and Setters
        public Long getTotalCount() { return totalCount; }
        public void setTotalCount(Long totalCount) { this.totalCount = totalCount; }
        public Long getActiveCount() { return activeCount; }
        public void setActiveCount(Long activeCount) { this.activeCount = activeCount; }
        public Long getIdleCount() { return idleCount; }
        public void setIdleCount(Long idleCount) { this.idleCount = idleCount; }
        public Long getTodayLoginCount() { return todayLoginCount; }
        public void setTodayLoginCount(Long todayLoginCount) { this.todayLoginCount = todayLoginCount; }
        public Double getAverageOnlineMinutes() { return averageOnlineMinutes; }
        public void setAverageOnlineMinutes(Double averageOnlineMinutes) { this.averageOnlineMinutes = averageOnlineMinutes; }
        public LocalDateTime getStatisticTime() { return statisticTime; }
        public void setStatisticTime(LocalDateTime statisticTime) { this.statisticTime = statisticTime; }
    }
    
    /**
     * 在线用户信息
     */
    public static class OnlineUserInfo {
        /**
         * 用户ID
         */
        private String userId;
        
        /**
         * 用户名
         */
        private String username;
        
        /**
         * 昵称
         */
        private String nickname;
        
        /**
         * 头像
         */
        private String avatar;
        
        /**
         * 部门名称
         */
        private String deptName;
        
        /**
         * 角色名称列表
         */
        private List<String> roleNames;
        
        /**
         * 会话ID
         */
        private String sessionId;
        
        /**
         * 客户端IP地址
         */
        private String clientIp;
        
        /**
         * 登录地点
         */
        private String loginLocation;
        
        /**
         * 浏览器信息
         */
        private String browser;
        
        /**
         * 操作系统
         */
        private String os;
        
        /**
         * 设备类型（mobile, desktop, tablet）
         */
        private String deviceType;
        
        /**
         * 设备信息
         */
        private String deviceInfo;
        
        /**
         * 用户代理字符串
         */
        private String userAgent;
        
        /**
         * 登录时间
         */
        private LocalDateTime loginTime;
        
        /**
         * 最后活跃时间
         */
        private LocalDateTime lastActiveTime;
        
        /**
         * 在线时长（分钟）
         */
        private Long onlineMinutes;
        
        /**
         * 会话剩余时间（秒）
         */
        private Long remainingSeconds;
        
        /**
         * 是否活跃（最近5分钟有活动）
         */
        private Boolean isActive;
        
        /**
         * 登录类型（web, mobile, api）
         */
        private String loginType;
        
        /**
         * 租户ID
         */
        private String tenantId;
        
        // Getters and Setters
        public String getUserId() { return userId; }
        public void setUserId(String userId) { this.userId = userId; }
        public String getUsername() { return username; }
        public void setUsername(String username) { this.username = username; }
        public String getNickname() { return nickname; }
        public void setNickname(String nickname) { this.nickname = nickname; }
        public String getAvatar() { return avatar; }
        public void setAvatar(String avatar) { this.avatar = avatar; }
        public String getDeptName() { return deptName; }
        public void setDeptName(String deptName) { this.deptName = deptName; }
        public List<String> getRoleNames() { return roleNames; }
        public void setRoleNames(List<String> roleNames) { this.roleNames = roleNames; }
        public String getSessionId() { return sessionId; }
        public void setSessionId(String sessionId) { this.sessionId = sessionId; }
        public String getClientIp() { return clientIp; }
        public void setClientIp(String clientIp) { this.clientIp = clientIp; }
        public String getLoginLocation() { return loginLocation; }
        public void setLoginLocation(String loginLocation) { this.loginLocation = loginLocation; }
        public String getBrowser() { return browser; }
        public void setBrowser(String browser) { this.browser = browser; }
        public String getOs() { return os; }
        public void setOs(String os) { this.os = os; }
        public String getDeviceType() { return deviceType; }
        public void setDeviceType(String deviceType) { this.deviceType = deviceType; }
        public String getDeviceInfo() { return deviceInfo; }
        public void setDeviceInfo(String deviceInfo) { this.deviceInfo = deviceInfo; }
        public String getUserAgent() { return userAgent; }
        public void setUserAgent(String userAgent) { this.userAgent = userAgent; }
        public LocalDateTime getLoginTime() { return loginTime; }
        public void setLoginTime(LocalDateTime loginTime) { this.loginTime = loginTime; }
        public LocalDateTime getLastActiveTime() { return lastActiveTime; }
        public void setLastActiveTime(LocalDateTime lastActiveTime) { this.lastActiveTime = lastActiveTime; }
        public Long getOnlineMinutes() { return onlineMinutes; }
        public void setOnlineMinutes(Long onlineMinutes) { this.onlineMinutes = onlineMinutes; }
        public Long getRemainingSeconds() { return remainingSeconds; }
        public void setRemainingSeconds(Long remainingSeconds) { this.remainingSeconds = remainingSeconds; }
        public Boolean getIsActive() { return isActive; }
        public void setIsActive(Boolean isActive) { this.isActive = isActive; }
        public String getLoginType() { return loginType; }
        public void setLoginType(String loginType) { this.loginType = loginType; }
        public String getTenantId() { return tenantId; }
        public void setTenantId(String tenantId) { this.tenantId = tenantId; }
    }
    
    /**
     * 会话分布统计
     */
    public static class SessionDistribution {
        /**
         * 按设备类型分布
         */
        private DeviceStats deviceStats;
        
        /**
         * 按浏览器分布
         */
        private BrowserStats browserStats;
        
        /**
         * 按时间分布
         */
        private TimeStats timeStats;
        
        public static class DeviceStats {
            private Long desktopCount = 0L;
            private Long mobileCount = 0L;
            private Long tabletCount = 0L;
            private Long unknownCount = 0L;
            
            // Getters and Setters
            public Long getDesktopCount() { return desktopCount; }
            public void setDesktopCount(Long desktopCount) { this.desktopCount = desktopCount; }
            public Long getMobileCount() { return mobileCount; }
            public void setMobileCount(Long mobileCount) { this.mobileCount = mobileCount; }
            public Long getTabletCount() { return tabletCount; }
            public void setTabletCount(Long tabletCount) { this.tabletCount = tabletCount; }
            public Long getUnknownCount() { return unknownCount; }
            public void setUnknownCount(Long unknownCount) { this.unknownCount = unknownCount; }
        }
        
        public static class BrowserStats {
            private Long chromeCount = 0L;
            private Long firefoxCount = 0L;
            private Long safariCount = 0L;
            private Long edgeCount = 0L;
            private Long ieCount = 0L;
            private Long otherCount = 0L;
            
            // Getters and Setters
            public Long getChromeCount() { return chromeCount; }
            public void setChromeCount(Long chromeCount) { this.chromeCount = chromeCount; }
            public Long getFirefoxCount() { return firefoxCount; }
            public void setFirefoxCount(Long firefoxCount) { this.firefoxCount = firefoxCount; }
            public Long getSafariCount() { return safariCount; }
            public void setSafariCount(Long safariCount) { this.safariCount = safariCount; }
            public Long getEdgeCount() { return edgeCount; }
            public void setEdgeCount(Long edgeCount) { this.edgeCount = edgeCount; }
            public Long getIeCount() { return ieCount; }
            public void setIeCount(Long ieCount) { this.ieCount = ieCount; }
            public Long getOtherCount() { return otherCount; }
            public void setOtherCount(Long otherCount) { this.otherCount = otherCount; }
        }
        
        public static class TimeStats {
            private Long morningCount = 0L;    // 6:00-12:00
            private Long afternoonCount = 0L;  // 12:00-18:00
            private Long eveningCount = 0L;    // 18:00-24:00
            private Long nightCount = 0L;      // 0:00-6:00
            
            // Getters and Setters
            public Long getMorningCount() { return morningCount; }
            public void setMorningCount(Long morningCount) { this.morningCount = morningCount; }
            public Long getAfternoonCount() { return afternoonCount; }
            public void setAfternoonCount(Long afternoonCount) { this.afternoonCount = afternoonCount; }
            public Long getEveningCount() { return eveningCount; }
            public void setEveningCount(Long eveningCount) { this.eveningCount = eveningCount; }
            public Long getNightCount() { return nightCount; }
            public void setNightCount(Long nightCount) { this.nightCount = nightCount; }
        }
        
        // Getters and Setters
        public DeviceStats getDeviceStats() { return deviceStats; }
        public void setDeviceStats(DeviceStats deviceStats) { this.deviceStats = deviceStats; }
        public BrowserStats getBrowserStats() { return browserStats; }
        public void setBrowserStats(BrowserStats browserStats) { this.browserStats = browserStats; }
        public TimeStats getTimeStats() { return timeStats; }
        public void setTimeStats(TimeStats timeStats) { this.timeStats = timeStats; }
    }
    
    // ==================== 主类 Getters and Setters ====================
    
    public OnlineStatistics getStatistics() { return statistics; }
    public void setStatistics(OnlineStatistics statistics) { this.statistics = statistics; }
    public List<OnlineUserInfo> getUsers() { return users; }
    public void setUsers(List<OnlineUserInfo> users) { this.users = users; }
    public SessionDistribution getSessionDistribution() { return sessionDistribution; }
    public void setSessionDistribution(SessionDistribution sessionDistribution) { this.sessionDistribution = sessionDistribution; }
}
